package com.etc.controller.mail;

import com.etc.common.ServiceException;

import com.etc.service.EmailService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Chen
 * @since 2021/1/17 - 0:46
 */
@RestController
public class MailController {
	@Autowired
	EmailService emailService;
	// localhost:8080/mail.action?to=597664265@qq.com&
		@GetMapping("mail")
		public String mailTask(String[] to) {
		try {
			// 邮箱， 内容， 目标邮件
			emailService.sendMail("This is title", "This is content", to);
			return "Send success";
		} catch (ServiceException e) {
			e.printStackTrace();
			return "Send failed";
		}
	}
}